package cn.fancy.sdk.utils;

import android.app.Activity;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;

/**
 * Created by zhaojh on date 2020/7/5
 */
public class SpMmkvUtils {
    
    //传入context时不能在application使用
    public static void init(Context context){
        //MMKV.initialize(context);
    }
    public static void putValue(Context context,String key, String value) {
      //  MMKV kv = MMKV.defaultMMKV();
        //kv.encode(key, value);
    
        SharedPreferences sp = context.getSharedPreferences("mmkv", Activity.MODE_PRIVATE);
        Editor editor = sp.edit();
        editor.putString(key, value);
        editor.commit();
    }
    
    public static String getValue(Context context, String key) {
        SharedPreferences sp = context.getSharedPreferences("mmkv", Activity.MODE_PRIVATE);
        return sp.getString(key, "");
        //MMKV kv = MMKV.defaultMMKV();
        //return kv.decodeString(key);
    }
    
    public static void remove(Context context, String key) {
        SharedPreferences sp = context.getSharedPreferences("mmkv", Activity.MODE_PRIVATE);
        Editor editor = sp.edit();
        editor.remove(key);
        editor.commit();
    }
    
    //========================================
    // 开启浮标
    public static final String KEY_FLOAT_DISPLAY="key_float_display";
    
    public static final String KEY_VERTICAL_ORIENTATION = "key_vertical_orientation";
    
    public static final String KEY_DISCOUNT = "KEY_DISCOUNT";
    
    // 浮标https用地址
    public static final String KEY_HTTPS_FLOAT_URL = "KEY_HTTPS_FLOAT_URL";
    
}
